package com.example.sls.controller.logistics;

import com.example.sls.pojo.logistics.Announcements;
import com.example.sls.service.intserfaces.logistics.AnnouncementsService;
import org.springframework.format.datetime.DateFormatter;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * 公告管理表(Announcements)表控制层
 *
 * @author 蓝江富
 * @since 2024-06-19 13:23:44
 */
@RestController
@RequestMapping("logistics/announcements")
public class AnnouncementsController {
  @Autowired
  AnnouncementsService announcementsService;
  @InitBinder
  public void initDateFormate(WebDataBinder dataBinder) {
    dataBinder.addCustomFormatter(new DateFormatter("yyyy-MM-dd HH:mm:ss"));
  }
  @GetMapping("queryById")
  Announcements queryById(Integer id) {
    return announcementsService.queryById(id);
  }
  @GetMapping("queryAllByLimit")
  List<Announcements> queryAllByLimit(Announcements announcements, Integer pageSize, Integer offset) {
    return announcementsService.queryAllByLimit(announcements, pageSize, offset);
  }
  @GetMapping("queryAll")
  List<Announcements> queryAll() {
    return announcementsService.queryAllByLimit(new Announcements(), 999999, 0);
  }
  @GetMapping("count")
  long count() {
    return announcementsService.count();
  }
  @GetMapping("insert")
  int insert(Announcements announcements) {
    return announcementsService.insert(announcements);
  }
  @GetMapping("update")
  int update(Announcements announcements) {
    return announcementsService.update(announcements);
  }
  @GetMapping("deleteById")
  int deleteById(Integer id) {
    return announcementsService.deleteById(id);
  }
}

